package com.cloudnote.web.service.impl;

import java.io.Serializable;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.cloudnote.web.dao.UserDaoI;
import com.cloudnote.web.model.User;
import com.cloudnote.web.service.UserServiceI;

@Component
public class UserServiceImpl implements UserServiceI {
	
	@Autowired
	private UserDaoI userDaoImpl;
	
	
	public void setUserDao(UserDaoI userDao) {
		this.userDaoImpl = userDao;
	}


	@Override
	public String addUser(User user) {
		Serializable uuid = userDaoImpl.save(user);
		 if (uuid == null){
	            return null;
	        }
		 System.out.println("id="+uuid.toString());
	     return uuid.toString();
	}


	@Override
	public List<User> getAllUser() {
		return userDaoImpl.getAllUser();
	}


	@Override
	public boolean delUser(String id) {
		return userDaoImpl.delUser(id);
	}


	@Override
	public User getUserByID(String id) {
		return userDaoImpl.getUserByID(id);
	}

	@Override
	public User getUserByName(String username) {
		return userDaoImpl.getUserByName(username);
	}

	@Override
	public boolean updateUser(User user) {
		return userDaoImpl.updateUser(user);
	}

}
